//
//  AyPhotoView.m
//  xWeibo
//
//  Created by alvis mac on 10/21/15.
//  Copyright © 2015 alvis. All rights reserved.
//

#import "AyPhotoView.h"
#import "UIImageExtend.h"
#import "UIImageView+WebCache.h"

@interface AyPhotoView ()
@property (nonatomic, weak)  UIImageView * gifView;
@end

@implementation AyPhotoView

- (instancetype)initWithFrame:(CGRect)frame{
    self=[super initWithFrame:frame];
    if (self) {
       UIImage *image = [UIImage imageWithName:@"timeline_image_gif"];
        UIImageView *gifView=[[UIImageView alloc]initWithImage:image];
        [self addSubview:gifView];
        self.gifView=gifView;
    }
    return self;
}


-(void)setPhoto:(AyPhoto *)photo{
    _photo=photo;
    self.gifView.hidden=![photo.thumbnail_pic hasSuffix:@"gif"];
    [self setImageWithURL:[NSURL URLWithString:photo.thumbnail_pic] placeholderImage:[UIImage imageWithName:@"timeline_image_placeholder"]];
}


- (void)layoutSubviews{
    [super layoutSubviews];
   self.gifView.layer.anchorPoint = CGPointMake(1, 1);
    self.gifView.layer.position = CGPointMake(self.frame.size.width, self.frame.size.height);
}
@end
